#ifndef RAINDROP_H_
#define RAINDROP_H_

#include "sceneObject.h"
#include "model/actions/particle.h"
#include <cstdlib>

class RainDrop : public SceneObject ,public Particle{
	private:
		Cube rainCube;
	public:
		RainDrop(const Cube& cube,const Cube& rainCube,const ObjectModelPtr& model)
			: SceneObject(cube,model),Particle(cube) {
			this->rainCube = cube;
			this->dropSpeed=-0.5f;
		}

		~RainDrop(){
		}

		void setModelMatrix(){
			SceneObject::setModelMatrix();
		}

		void notifyParticlePositionChange(float vel=0){
			this->dimensions.translate(0,0,vel);
			if(this->dimensions.maxZ()<0)
				notifyCollided(NULL);
		}

		void notifyCollided(Solid* obj){
			Point randp;
			randp.x1 = ((float)rand()/(float)RAND_MAX)*(rainCube.width()) + rainCube.minX();
			randp.x2 = ((float)rand()/(float)RAND_MAX)*(rainCube.depth()) + rainCube.minY();
			randp.x3 = ((float)rand()/(float)RAND_MAX)*(rainCube.center().x3);

			this->dimensions.center(randp);
			this->getSize().center(randp);
		}

		void setRainCube(const Cube& cube){
			this->rainCube=cube;
		}

		static std::string name(){
			return "drop";
		}

		virtual void accelerate(float accel){
			this->dropSpeed+=accel;
		}
};


#endif /* RAINDROP_H_ */
